package com.bigben.firTry;

import com.bigben.entities.Apples;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by zhaoben on 2016/12/1.
 */
public class improveFillter {
    public List<Apples> improveFillter(List<Apples> apples, String color, int weight, Boolean flag){
        List<Apples> results = new ArrayList<Apples>();
        for (Apples apple : apples) {
            if((flag && color.equals(apple.getColor())) || (!flag && apple.getWeight() > weight)){
                results.add(apple);
            }
        }
        return results;
    }
}
